package controller

import (
	"admin/model"
	"common/helper"
	"encoding/json"
	"github.com/valyala/fasthttp"
)

type CsController struct{}

func (that *CsController) List(ctx *fasthttp.RequestCtx) {

	data, err := model.CsList()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, data)
}

func (that *CsController) Update(ctx *fasthttp.RequestCtx) {

	var param model.CSForm

	b := ctx.PostBody()

	err := json.Unmarshal(b, &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}

	err = model.CsUpdate(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, "成功")
}
